package com.hellobike.haxing.test.wms;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;

public class WmsLocationGenerator {
    public static void main(String[] args) throws FileNotFoundException {
        //A01-001常温
        PrintWriter writer = new PrintWriter(new FileOutputStream(WmsLocationGenerator.class.getClassLoader().getResource("").getPath()+"/wms-location.sql"));
        for (int i = 0; i < 400; i++) {
            writer.println("INSERT INTO \"t_wms_location\" (\"loc_code\",\"loc_name\", \"loc_type\", \"loc_status\", \"warehouse_id\", \"partition_id\", \"partition_code\",\"create_time\", \"update_time\", \"deleted\") \n" +
                    "VALUES ('F01-"+formatI(i+1)+"','', 'QT', 'OPEN', 1, 4,'F01-001', NOW(), NOW(), 0 );");
        }
//        for (int i = 0; i < 400; i++) {
//            writer.println("INSERT INTO \"t_wms_location\" (\"loc_code\", \"loc_type\", \"loc_status\", \"warehouse_id\", \"partition_id\", \"partition_code\",\"create_time\", \"update_time\", \"deleted\") \n" +
//                    "VALUES ('B01-"+formatI(i+1)+"', 'LC', 'OPEN', 1, 1,'LC-001', NOW(), NOW(), 0 );");
//        }
//        for (int i = 0; i < 400; i++) {
//            writer.println("INSERT INTO \"t_wms_location\" (\"loc_code\", \"loc_type\", \"loc_status\", \"warehouse_id\", \"partition_id\", \"partition_code\",\"create_time\", \"update_time\", \"deleted\") \n" +
//                    "VALUES ('C01-"+formatI(i+1)+"', 'LD', 'OPEN', 1, 2,'LD-001', NOW(), NOW(), 0 );");
//        }
        writer.flush();
        writer.close();
    }

    private static String formatI(int i) {
        if(i<10){
            return "00"+i;
        }
        if(i<100){
            return "0"+i;
        }
        return String.valueOf(i);
    }
}
